<?php
class mdescriptioncontent extends CI_Model{
	var $description = "description_content";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_description,$id_submenu,$title_description,$date_description,$text_description,$file_description)
	{
		$this->id_description = $id_description;
		$this->id_submenu = $id_submenu;
		$this->title_description = $title_description;
		$this->date_description = $date_description;
		$this->text_description = $text_description;
		$this->file_description = $file_description;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->description, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getComboList(){
		$query = $this->db->get($this->description);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_description'=>$this->id_description,
			'id_submenu'=>$this->id_submenu,
			'title_description'=>$this->title_description,
			'date_description'=>$this->date_description,
			'text_description'=>$this->text_description,
			'file_description'=>$this->file_description
		);
		return $this->db->insert($this->description, $arrayData);
	}
	
	function update($id_description)
	{
		$arrayData = array(
			'id_submenu'=>$this->id_submenu,
			'title_description'=>$this->title_description,
			'date_description'=>$this->date_description,
			'text_description'=>$this->text_description,
			'file_description'=>$this->file_description
		);
		$this->db->where('id_description', $id_description);
		return $this->db->update($this->description, $arrayData);
	}
        
	function remove($id_description)
	{
		$this->db->where('id_description', $id_description);
		return $this->db->delete($this->description);
	}	
	
	function detail($id_description)
	{
		$this->db->where('id_description', $id_description);
		$query = $this->db->get($this->description);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('title_description',$name);
		$query = $this->db->get($this->description);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function getForWeb($id_submenu)
	{
		$this->db->where('id_submenu', $id_submenu);
		$query = $this->db->get($this->description);	
		return $query->result_array();
	}
}
?>